home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 5.5 KB | 177 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWAlert.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWALERT_H
- #define FWALERT_H
-
- // ----- Foundation Includes -----
-
- #ifndef FWCOMMON_H
- #include "FWCommon.h"
- #endif
-
- #ifndef FWSTRING_H
- #include "FWString.h"
- #endif
-
- // ----- Macintosh includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__TYPES__)
- #include <Types.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__DIALOGS__)
- #include <Dialogs.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__EVENTS__)
- #include <Events.h>
- #endif
-
- // ----- Windows includes -----
-
- #if defined(FW_BUILD_WIN) && !defined(_INC_WINDOWS)
- #include <Windows.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- //========================================================================================
- // Constants
- //========================================================================================
-
- typedef short FW_AlertResult;
- typedef short FW_ButtonType;
- typedef short FW_IconType;
- typedef short FW_DefaultButton;
-
- #ifdef FW_BUILD_MAC
- const FW_ButtonType FW_kOK = 0x0000;
- const FW_ButtonType FW_kOKCancel = 0x0001;
- const FW_ButtonType FW_kAbortRetryIgnore = 0x0002;
- const FW_ButtonType FW_kYesNoCancel = 0x0003;
- const FW_ButtonType FW_kYesNo = 0x0004;
- const FW_ButtonType FW_kRetryCancel = 0x0005;
-
- const FW_IconType FW_kStopAlert = 0x0010;
- const FW_IconType FW_kCautionAlert = 0x0020;
- const FW_IconType FW_kNoteAlert = 0x0040;
-
- const FW_DefaultButton FW_kDefaultButton1 = 0x0000;
- const FW_DefaultButton FW_kDefaultButton2 = 0x0100;
- const FW_DefaultButton FW_kDefaultButton3 = 0x0200;
-
- enum EAlertResultConstants
- {
- FW_kOKButtonPressed = 1,
- FW_kCancelButtonPressed = 2,
- FW_kAbortButtonPressed = 3,
- FW_kRetryButtonPressed = 4,
- FW_kIgnoreButtonPressed = 5,
- FW_kYesButtonPressed = 6,
- FW_kNoButtonPressed = 7
- };
- #endif
-
- #ifdef FW_BUILD_WIN
- const FW_ButtonType FW_kOK = MB_OK;
- const FW_ButtonType FW_kOKCancel = MB_OKCANCEL;
- const FW_ButtonType FW_kAbortRetryIgnore = MB_ABORTRETRYIGNORE;
- const FW_ButtonType FW_kYesNoCancel = MB_YESNOCANCEL;
- const FW_ButtonType FW_kYesNo = MB_YESNO;
- const FW_ButtonType FW_kRetryCancel = MB_RETRYCANCEL;
-
- const FW_IconType FW_kStopAlert = MB_ICONHAND;
- const FW_IconType FW_kCautionAlert = MB_ICONQUESTION;
- const FW_IconType FW_kNoteAlert = MB_ICONASTERISK;
-
- const FW_DefaultButton FW_kDefaultButton1 = MB_DEFBUTTON1;
- const FW_DefaultButton FW_kDefaultButton2 = MB_DEFBUTTON2;
- const FW_DefaultButton FW_kDefaultButton3 = MB_DEFBUTTON3;
-
- enum EAlertResultConstants
- {
- FW_kOKButtonPressed = IDOK ,
- FW_kCancelButtonPressed = IDCANCEL,
- FW_kAbortButtonPressed = IDABORT ,
- FW_kRetryButtonPressed = IDRETRY,
- FW_kIgnoreButtonPressed = IDIGNORE,
- FW_kYesButtonPressed = IDYES,
- FW_kNoButtonPressed = IDNO
- };
- #endif
-
- //========================================================================================
- // class FW_CAlert
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CAlert
- {
- public:
- static FW_AlertResult DoAlert(const FW_CString& documentName,
- const FW_CString& message,
- FW_ButtonType buttonType,
- FW_IconType iconType,
- FW_DefaultButton defaultButton,
- FW_Boolean beep);
-
- static FW_AlertResult DoNote(const FW_CString& documentName, const FW_CString& message);
- static FW_AlertResult DoQuestion(const FW_CString& documentName, const FW_CString& message, FW_DefaultButton defaultButton);
- static FW_AlertResult DoError(const FW_CString& documentName, const FW_CString& message);
-
- #ifdef FW_BUILD_MAC
- public:
- static pascal Boolean MacAlertDialogFilter(DialogPtr theDialog,
- EventRecord *theEvent,
- short *itemHit);
-
- private:
- static short gOkItemId;
- static short gCancelItemId;
- #endif
- };
-
- //----------------------------------------------------------------------------------------
- // DoNote
- //----------------------------------------------------------------------------------------
- inline FW_AlertResult FW_CAlert::DoNote(const FW_CString& documentName, const FW_CString& message)
- {
- return DoAlert(documentName, message, FW_kOK, FW_kNoteAlert, FW_kDefaultButton1, TRUE);
- }
-
- //----------------------------------------------------------------------------------------
- // DoQuestion
- //----------------------------------------------------------------------------------------
- inline FW_AlertResult FW_CAlert::DoQuestion(const FW_CString& documentName,
- const FW_CString& message,
- FW_DefaultButton defaultButton)
- {
- return DoAlert(documentName, message, FW_kYesNo, FW_kCautionAlert, defaultButton, TRUE);
- }
-
- //----------------------------------------------------------------------------------------
- // DoError
- //----------------------------------------------------------------------------------------
- inline FW_AlertResult FW_CAlert::DoError(const FW_CString& documentName, const FW_CString& message)
- {
- return DoAlert(documentName, message, FW_kOK, FW_kStopAlert, FW_kDefaultButton1, TRUE);
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-